package models;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import play.db.ebean.Model;

@Entity
public class Questao extends Model{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public long id;
	
	public String enunciadoText;
	
	@Lob
	public byte[] enunciadoImage;
	
	public boolean showEnunciadoImage;
	
	public int niveldificuldade;
	
	@Temporal(TemporalType.DATE)
	public Date dtCadastro;
	
	@ManyToMany(cascade=CascadeType.MERGE, fetch=FetchType.EAGER)
	@JoinTable(name="Questao_Tema", joinColumns = { @JoinColumn(name = "questao_id") }, inverseJoinColumns = { @JoinColumn(name = "tema_id") })
	public List<Tema> temas = new ArrayList<Tema>();

	public String sTemas;
	
	@ManyToMany(cascade=CascadeType.MERGE, fetch=FetchType.EAGER)
	@JoinTable(name="Questao_Opcao", joinColumns = { @JoinColumn(name = "questao_id") }, inverseJoinColumns = { @JoinColumn(name = "opcao_id") })
	public List<Opcao> opcoes = new ArrayList<Opcao>();
	
	@ManyToMany(cascade=CascadeType.MERGE, fetch=FetchType.EAGER)
	@JoinTable(name="Questao_Opcao_Correta", joinColumns = { @JoinColumn(name = "questao_id") }, inverseJoinColumns = { @JoinColumn(name = "opcao_id") })
	public List<Opcao> opcaoCorreta = new ArrayList<Opcao>();
}
